<template>
  <basic-container>
    <basic-header title="维修服务列表" />
    <apply-table ref="table" :action="action" :addBtn="false" :editBtn="false" :deleteBtn="false" :subTitle="subTitle">
      <template slot="slot-orderStatus" slot-scope="{data}">
        <span :class="{'text-waring': data === 'NOT_RECEIVING'}">{{data | orderStatus}}</span>
      </template>
      <template slot-scope="{ row }" slot="applyMenu">
        <el-button plain type="success" size="small" v :icon="el-icon-upload2" @click.stop="handleChange(row)">指派</el-button>
      </template>
    </apply-table>
  </basic-container>
</template>
<script>
import ApplyTable from "@/components/ApplyTable";
import actionTypes from "@/const/action";
import { mapMutations } from "vuex";
import { orderStatus } from "@/const/types";
import { SyncRequestReceiving } from "@/api/config";

export default {
  name: "account",
  components: { ApplyTable },
  filters: {
    orderStatus(status) {
      return orderStatus[status] || "未接单";
    }
  },
  data() {
    return {
      action: actionTypes.MAINTAIN_ORDER,
      unReceiving: 0
    };
  },
  computed: {
    subTitle() {
      return `未接订单数: ${this.unReceiving}`;
    }
  },
  async created() {
    const result = await SyncRequestReceiving();
    if (result.error) {
      this.$message({
        type: "error",
        message: result.error.message || String(result.error)
      });
      return;
    }
    this.unReceiving = result.data.data.bussData;
  },
  methods: {
    ...mapMutations({
      setCurrentData: "table/SET_CURRENT_DATA"
    }),
    handleChange(row) {
      this.setCurrentData({
        designateFrom: row.id
      });
      this.$router.push("/wel/staffChoose");
    }
  }
};
</script>
<style>
</style>

